<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>我的订单</title>
    <link rel="stylesheet" href="/admin/css/categoryManage.css">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <script type="text/javascript" src="/static/js/jquery-3.6.0.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        table{
            margin: 0 auto;
        }
        table tr{
            height: 30px;
        }
        table td{
            width: 134px;
            margin-left: 5px;
        }
    </style>
</head>
<body><h2 style="text-align: center">我的订单</h2>
    <div>
        <table id="table-one" cellpadding="2px" cellspacing="1px" border="1px">

        </table>
        <input type="hidden" name="uid" id="uid" value="${loginUser.id}"/>
    </div>
<script>
    $(function () {
        //展示订单数据
        $.getJSON("/order.do",{method:"showOrderByUserId",uid:$("#uid").val()},function (orders) {
            console.log(orders);
            if (orders == null) {
                alert("您还没有订单！")
            } else {
                $("#table-one").html("");
                //表头
                let $id =$("<td>订单编号</td>");
                let $name =$("<td>用户</td>");
                let $address =$("<td>地址</td>");
                let $money =$("<td>价格</td>");
                let $ordername =$("<td>订单名字</td>");

                let $tr = $("<tr></tr>");
                $tr.append($id).append($name).append($address).append($money).append($ordername);
                $("#table-one").append($tr);
                for (let i = 0; i < orders.length; i++) {
                    let $id =$("<td>"+orders[i].id+"</td>");
                    let $name =$("<td>"+orders[i].accept+"</td>");
                    let $address =$("<td>"+orders[i].address+"</td>");
                    let $money =$("<td>"+orders[i].money+"</td>");
                    let $ordername =$("<td>"+orders[i].ordername+"</td>");

                    let $tr = $("<tr></tr>");
                    $tr.append($id).append($name).append($address).append($money).append($ordername);
                    $("#table-one").append($tr);
                }
            }
        })
    })

</script>
</body>
</html>
